<%@page import="com.dfhc.util.CryptoHelper"%>
<%@ page contentType="text/html; charset=UTF-8" session="false" language="java" %>
<div class="modal" ng-controller="KisBpmFormKeyPopupCtrl">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="close()">&times;</button>
    <h2 translate>PROPERTY.FORMKEY.TITLE</h2>
</div>
<div class="modal-body">

    <div class="detail-group clearfix">
        
        <div class="form-group clearfix">
            <div class="col-xs-12">
                <label class="col-xs-3">{{'PROPERTY.FORMKEY.STATIC' | translate}}</label>
                <div class="col-xs-9">
                	<input id="formKeyName" class="form-control" type="text" readonly="readonly" ng-model="formKey.value"  />
                    <button onclick="javascript:selectTemplate();" class="btn btn-primary" translate>ACTION.SELECT_TEMPLATE</button>
                </div>
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button ng-click="save()" class="btn btn-primary" translate>ACTION.SAVE</button>
        <button ng-click="close()" class="btn btn-primary" translate>ACTION.CANCEL</button>
    </div>
</div>
</div>
</div>
</div>

<!--begin编辑 输入框弹出层 -->

  <div id="outer" class="outer-div" >  
  </div>  
  <div id="inner" class="inner-div" > 
  
  <div class="content-div">
	  <div class="tan_close_div">
	     <a href="javascript:void(0);"  onclick="javascript:close_tan()" >×</a>
	  </div>
	  
	  <!-- 加载iframe -->
	  <div class="frame_div" id="frame_div">
	  
	   <iframe  name="template_frame" id="template_frame">
	   
	
	   
	   </iframe>
	  
	  </div>
      <!-- end 加载iframe -->
      
	  <div class="tan_btn_div">
	    <a href="javascript:void(0);" class="assignee_ok" onclick="javascript:assignee_ok()"> 确定选择</a>
	    <a href="javascript:void(0);" class="assignee_cancel" onclick="javascript:close_tan()"> 取消选择</a>
	  </div>
 
  </div>
</div>  
<script type="text/javascript">
//选择页面模板
function selectTemplate(){
		jQuery("#frame_div").find("iframe").prop("src","${pageContext.request.contextPath }<%=CryptoHelper.encryptUrl(request,"/formtemplate")%>");
		jQuery("#outer").addClass("show");
		jQuery("#inner").addClass("show");
}
//选择需要的用户
function assignee_ok(){
	debugger;
    var frame_pointer=jQuery("#template_frame").contents().find(".cbox");//获取iframe中的input内容保存指正指向

    var select_num=0;
    var data=new Array();
    var id;
    var name;
    //var thisInputObj = referenceContent.document.getElementsByClassName('cbox');
	for(var j=0; j<frame_pointer.length; j++){  //循环checkbox组
          var ele=frame_pointer[j];

          if(jQuery(ele).is(":checked")){//选中
		     select_num  = select_num +1;
             var pointer=jQuery(ele).parents("tr");//保存选中行的指针
			 id=jQuery(pointer).attr("id");//选中行的id
			 jQuery(pointer).find("td").each(function() {
     				    //查询td的aria-describedby="grid-table_key"
						var propertyKeyValue = jQuery(this).attr("aria-describedby");
						
					   if(propertyKeyValue == "grid-table_templateName"){
        					var tdText=jQuery(this).html();
        					tdText=jQuery.trim(tdText);
        					if(tdText =="&nbsp;"){
        					  tdText ="";
        					 }
        					 name = tdText;
    					   }
     					}
     					);
		}
    }    
    
	
	if(select_num==0){
		alert("请至少选择一条数据");
		return false;
	}
	if(select_num>1){
		alert("最多只能选择一条数据");
		return false;
	}
	var appElement = document.querySelector('[ng-controller=KisBpmFormKeyPopupCtrl]');
    var _scope = angular.element(appElement).scope();
    _scope.formKey={'value':name};    
    _scope.$apply();
	close_tan();
}
//取消窗口
function close_tan(){
	
	jQuery("#outer").hide().removeClass("show");
	jQuery("#inner").hide().removeClass("show");
	
	
	jQuery("#frame_div").find("iframe").html("");
	jQuery("#frame_div").find("iframe").prop("scr","");
}
</script>
  